import axios from "axios";

const baseApi = 'http://101.35.231.245:1073'
export const websocketUrl = 'ws://101.35.231.245:1080/webSocket/'
//const baseApi = 'http://localhost:1073'
//export const websocketUrl = 'ws://localhost:1080/webSocket/'


/**
 * @Author 时啟轩
 * 登录页面
 */
//token校验
export const signTestPost = (token)=>axios.post(
    baseApi+'/auth1074/test',
    null,
    {
        headers:{
            Authorization:'Bearer '+token
        }
    })
//检查是否有代拿用户权限
export const deliverTestPost = (token)=>axios.post(
    baseApi+'/auth1074/deliver/test',
    null,
    {
        headers:{
            Authorization:'Bearer '+token
        }
    })
//检查是否有管理员权限
export const managerTestPost = (token)=>axios.post(
    baseApi+'/auth1074/manager/test',
    null,
    {
        headers:{
            Authorization:'Bearer '+token
        }
    })
//登录
export const signInPost = (phoneNum, password)=>axios.post(
    baseApi + '/auth1074/sign/signInCheck',
    null,
    {
        params:{
            phoneNum: phoneNum,
            password: password
        }
    }
)
//获取验证码
export const getPhoneCode = (phoneNum, mode)=>axios.post(
    baseApi + '/auth1074/sign/getPhoneCode',
    null,
    {
        params:{
            phoneNum: phoneNum,
            mode: mode
        }
    }
)
//注册
export const signUpPost = (phoneNum, password, mode, code)=>axios.post(
    baseApi + '/auth1074/sign/signUp',
    null,
    {
        params:{
            phoneNum: phoneNum,
            password: password,
            mode: mode,
            code: code,
        }
    }
)
//重设密码
export const resetPassword = (phoneNum, mode, code, newPassword)=> axios.post(
    baseApi + '/auth1074/sign/resetPassword',
    null,
    {
        params:{
            phoneNum: phoneNum,
            mode: mode,
            code: code,
            newPassword: newPassword
        }
    }
)
//获取用户id
export const getUserId = (token)=>axios.post(
    baseApi+'/auth1074/getUserId',
    null,
    {
        headers:{
            Authorization:'Bearer '+token
        }
    })

/**
 * @Author 时啟轩
 * 消息
 */
//获取所有对话
export const getAllDialogues = (token)=>axios.post(
    baseApi+'/message1080/dialogue/all/getAllDialogues',
    null,
    {
        headers:{
            Authorization:'Bearer '+token
        }
    }
)
//获取某对话所有消息
export const getAllMessages = (token, dialogueId)=>axios.post(
    baseApi+'/message1080/message/selectMessages',
    null,
    {
        params:{
            dialogueId:dialogueId
        },
        headers:{
            Authorization:'Bearer '+token
        }
    }
)
//存储httpsession
export const saveSession = (token, userId)=>axios.post(
    baseApi+'/message1080/saveSession',
    null,
    {
        params:{
            userId:userId
        },
        headers:{
            Authorization:'Bearer '+token
        }
    }
)
//消息图片接口
export const messageImgUrl = baseApi + '/hwobs9373/obs/getMessagePicture'
